package demo.practice.array;

public class P724_2 {

    public int pivotIndex(int[] nums) {

        int sum = 0;

        for (int i = 0; i < nums.length; i++) {
            sum += nums[i];
        }

        int sum2 = 0;
        for (int i = 0; i < nums.length; i++) {
            if (sum2 == sum - nums[i] - sum2) {
                return i;
            }
            sum2 += nums[i];
        }

        return -1;

    }
}
